package com.data.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper;
import org.springframework.stereotype.Repository;

import com.base.dao.TemplateDaoImpl;
import com.data.entity.DeviceEnergyData;
@Repository("deviceEnergyDataDao")
public class DeviceEnergyDataDaoImpl extends TemplateDaoImpl<DeviceEnergyData, Long>implements DeviceEnergyDataDao{
	/**
	 * 查询时间段内的实时数据记录
	 * @param equNo
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	@Override
	public List<DeviceEnergyData> getEnergyDataByAreaDate(String startTime, String endTime) {
		String sql="select * from deviceEnergyData where DATE_FORMAT(collectTime,'%Y-%m-%d %H:%i:%s')>=:startTime and  DATE_FORMAT(collectTime,'%Y-%m-%d %H:%i:%s')<:endTime  order by collectTime asc";
		Map<String, Object> params=new HashMap<String, Object>();
		params.put("startTime", startTime);
		params.put("endTime", endTime);
		return jt.query(sql, params, ParameterizedBeanPropertyRowMapper.newInstance(DeviceEnergyData.class));
	}
}
